package com.zzs.library.service.impl;

import com.github.pagehelper.PageHelper;
import com.zzs.library.mbg.mapper.BookMapper;
import com.zzs.library.mbg.model.Book;
import com.zzs.library.mbg.model.BookExample;
import com.zzs.library.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author ZechariahZheng
 * @Date 2020/1/6 16:13
 * @Version 1.0
 * @description
 */
@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;

    @Override
    public List<Book> listAllBook() {
        return bookMapper.selectByExample(new BookExample());
    }

    @Override
    public List<Book> listBook(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return bookMapper.selectByExample(new BookExample());
    }

    @Override
    public Book getBook(Long id) {
        return bookMapper.selectByPrimaryKey(id);
    }
}
